 import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {FormBuilder, FormGroup, Validators} from "@angular/forms";

/**
 * Generated class for the DetailDemoPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-detail-demo',
  templateUrl: 'detail-demo.html',
})
export class DetailDemoPage {
  selectedItem: any;
  type:String;
  public myForm:FormGroup;

  constructor(public navCtrl: NavController, public navParams: NavParams,public formBuilder:FormBuilder) {
    this.selectedItem = this.navParams.get("item");
    this.type = this.navParams.get("type");
    console.debug(this.selectedItem);

    this.myForm=this.formBuilder.group({
      field1:[this.selectedItem.cId.value,Validators.required],
      field2:[this.selectedItem.userName.value],
      field3:['cc']
    });
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad DetailDemoPage');
  }

  saveForm(event){
    event.preventDefault();
    console.log(this.myForm.value);
  }

}
